<?php

namespace App\Observers\Train;

use App\Models\Train\TrainIssues\TrainIssue;
use Illuminate\Support\Facades\Cache;

class TrainIssueObserver
{


    /**
     * Handle the TrainIssue "created" event.
     *
     * @param TrainIssue $issue
     * @return void
     */
    public function created(TrainIssue $issue)
    {
        $cache_key = "Issue:issue_id:{$issue->issue_id}";
        Cache::put($cache_key, $issue, config('trip.ttl.day'));
    }

    /**
     * Handle the TrainIssue "updated" event.
     *
     * @param TrainIssue $issue
     * @return void
     */
    public function updated(TrainIssue $issue)
    {
        $cache_key = "Issue:issue_id:{$issue->issue_id}";
        Cache::put($cache_key, $issue, config('trip.ttl.day'));
    }

    public function saved(TrainIssue $issue)
    {
        $cache_key = "Issue:issue_id:{$issue->issue_id}";
        Cache::put($cache_key, $issue, config('trip.ttl.day'));
    }
}
